{extend name="index_layout"/}
{block name="main"}
<form class="layui-form" method="post">

    <div class="layui-form-item">
        <label class="layui-form-label">日期</label>
        <div class="layui-input-block">
            <input type="text" name="row[date]" id="date1" autocomplete="off" value="{$data.date}" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">店铺</label>
        <div class="layui-input-block">
            {:Form::selectpage("row[did]",$data.did,'admin/cate/index','name','id',["lay-verify"=>"required"])}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">主持</label>
        <div class="layui-input-block">
            <input id="c-zhuchi" class=" layui-input" name="row[zhuchi]" type="text"
                   value="{$data.zhuchi}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">刷单数</label>
        <div class="layui-input-block">
            <input id="c-nums" lay-verify="required" class=" layui-input" name="row[nums]" type="number"
                   value="{$data.nums}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">单价</label>
        <div class="layui-input-block">
            <input id="c-price" lay-verify="required" class=" layui-input" step="0.01" name="row[price]" type="number"
                   value="{$data.price}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">付款金额</label>
        <div class="layui-input-block">
            <input id="c-money" lay-verify="required" class=" layui-input" step="0.01" name="row[money]" type="number"
                   value="{$data.money}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品单价</label>
        <div class="layui-input-block">
            <input id="c-goods-price" lay-verify="required" class=" layui-input" step="0.01" name="row[goods_price]"
                   type="number" value="{$data.goods_price}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">支出总金额</label>
        <div class="layui-input-block">
            <input id="c-total-money" lay-verify="required" readonly class=" layui-input" step="0.01"
                   name="row[total_money]" type="number" value="{$data.total_money}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            {:Form::textarea('row[notes]',$data.notes)}
        </div>
    </div>

    <div class="layui-form-item layer-footer">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use(['yznForm', 'laydate'], function () {
        var yznForm = layui.yznForm;
        var laydate = layui.laydate;
        laydate.render({
            elem: '#date1'
        });
        yznForm.bindevent($("form.layui-form"));
    });


    $('#c-price').blur(function () {
        var nums = $('#c-nums').val()
        var price = $('#c-price').val()
        if (nums && price) {
            $('#c-money').val(nums * price)
        }

    });


    $('#c-goods-price').blur(function () {
        var nums = $('#c-nums').val()
        var price = Number($('#c-price').val())
        var goods_price = Number($('#c-goods-price').val())
        if (nums && price && goods_price) {
            console.log(price + goods_price)
            $('#c-total-money').val((price + goods_price) * nums)
        }


    })


    $('#c-nums').blur(function () {
        var nums = $('#c-nums').val()
        var price = $('#c-price').val()
        if (nums && price) {
            $('#c-money').val(nums * price)
        }

    });


</script>
{/block}